package cn.itsource;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

@RunWith(SpringRunner.class)
@SpringBootTest(classes = SpringBootRabbitmqDemo.class)
public class Send {
    @Autowired
    private RabbitTemplate rabbitTemplate;

    @Test
    public void SendTest(){
        for (int i = 0; i < 20; i++) {
            String message = "send message to user:"+i;
            if (i%2==0){

                rabbitTemplate.convertAndSend(RabbitmqConfig.EXCHANGE_TOPICS_INFORM,
                        "email.hahaha",message);
            }else {
                rabbitTemplate.convertAndSend(RabbitmqConfig.EXCHANGE_TOPICS_INFORM,
                        "sms.hahaha",message);
            }
        }
    }
}
